<?php
	class Module
	{
		protected $module_params = array();
		function Module()
		{
			
		}
		function FireEvent($event)
		{
			if(!method_exists($this, 'on'.$event))
				return;
			call_user_method('on'.$event, $this);
		}
		function Params(){return $this->module_params;}
		function Param($key)
		{
			if(array_key_exists($key, $this->module_params))
				return $this->module_params[$key];
			else
				new Err(__T('field not found'));
		}
		function loadParams($path)
		{
			$this->module_params['class_name'] = basename($path);
			if(file_exists($path.'/languages/'.Sslib::Variable('sslib.language')))
				$path = $path.'/languages/'.Sslib::Variable('sslib.language');
			else if(file_exists($path.'/languages/en'))
				$path = $path.'/languages/en';
			else
			{
				new Err(__T('missing localization file'));
				$path = null;
			}
			if($path === null) return false;
			
			$this->module_params = array_merge($this->module_params, Sslib::LoadSettings($path));
			
			return true;
		}
		public function path()
		{
			return 'modules/'.$this->module_params['class_name'].'/';
		}
	}
?>